#ifndef UDPSENDER_H
#define UDPSENDER_H

#include <QThread>
#include <QUdpSocket>
#include <QQueue>
#include <QMutex>
#include "Define.h"

class UDPSender : public QThread
{
	Q_OBJECT
	public:
		UDPSender();
		void Initialize();
		void SendDatagram(QByteArray packet);
		void SendDatagram(QByteArray packet, int port);
		void SendDatagram(QByteArray packet, QHostAddress addr, int port);

	protected:
		void run();

	private:
		void Enqueue(QByteArray packet, QHostAddress addr, int port);

	private:
		QUdpSocket _socket;
		QQueue<UDPPacket *> _sendQueue;
		bool _init;
		QMutex _mutex;
};

#endif // UDPSENDER_H
